import {createRouter, createWebHistory} from 'vue-router'
import NonExistent from "@/views/NonExistent.vue";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
          path:"/",
          component:()=>import("@/views/Login.vue"),
        },
        {
            path: "/home",
            component: ()=>import('../views/Home.vue'),
        },
        {
            path: "/user",
            component: ()=>import('../views/User.vue')
        },
        {
            path: "/dict",
            component: ()=>import('../views/Dict.vue'),
        },
        {
            path: "/article",
            children: [
                {
                    path: ":id",
                    component: ()=>import("../views/Article.vue"),
                },
                {
                    path: "update/:id",
                    component: ()=>import("../views/FormArticle.vue")
                },
                {
                    path: "create/:id",
                    component: ()=>import("../views/FormArticle.vue")
                }
            ]
        },
        // 在app.vue中已经封装全部组件，因此不需要占位符
        {
            path: "/literature",
            children: [
                {
                    path: ":id",
                    component: ()=>import("../views/Literature.vue"),
                },
                {
                    path: "create/:id",
                    component: ()=>import("../views/FormLiterature.vue")
                },
                {
                    path: "update/:id",
                    component: ()=>import("../views/FormLiterature.vue")
                }
            ]
        },
        {
            path: "/region/:id",
            component: ()=>import("../views/Region.vue")
        },
        {
            path:"/:pathMatch(.*)*",
            component:()=>import("@/views/NonExistent.vue")
        },
    ]
});
export default router;